package objectClasses;
import java.io.IOException;
import java.util.ArrayList;

public class UserInfo
{
	public static ArrayList<UserInfo> users = new ArrayList<UserInfo>();
	public static final char ATENDEE = 'A';
	public static final char ORGANIZER = 'O';
	public static final char JUDGE = 'J';
	public static final char CONTESTANT = 'C';
	/**
	 * User's First Name
	 */
	private String firstName;
	
	/**
	 * User's Last Name
	 */
	private String lastName;
	
	/**
	 * User's login userName
	 */
	private String userName;
	
	/**
	 * the User's e-mail address;
	 */
	private String eMail;
	
	/**
	 * Defines the type of user
	 */
	private char userType;
	
	/**
	 * The User's phone number
	 */
	private String phoneNumber;
	
	/**
	 * Constructs a new UserInfo with the given information
	 * @author Diana Gorun
	 * @param type
	 * @param first
	 * @param last
	 * @param email
	 * @param user
	 * @throws IOException
	 */
	public UserInfo(char type, String first, String last, String email, String user, String phoneNum)throws IOException 
	{
		super();
		firstName = first;
		lastName = last;
		userName = user;
		eMail = email;
		userType = type;
		phoneNumber = phoneNum;
	}
	
	//Setters
	/**
	 * Sets this User's email address
	 * @author Diana Gorun
	 * @param email
	 */
	public void setAddress(String email) 
	{
		eMail = email;
	}
	
	/**
	 * Sets the User's username
	 * @author Diana Gorun
	 * @param username
	 */
	public void setUsername(String username) 
	{
		userName = username;
	}
	
	/**
	 * Sets the User's first name
	 * @author Diana Gorun
	 * @param first_Name
	 */
	public void setFirstName(String first_Name) 
	{
		firstName = first_Name;
	}
	
	/**
	 * Set's the user's last name
	 * @author Diana Gorun
	 * @param last_Name
	 */
	public void setLastName(String last_Name) 
	{
		lastName = last_Name;
	}
	
	/**
	 * Sets the user's status
	 * @author Diana Gorun
	 * @param user_type
	 */
	public void setUserType(char user_type)
	{
		userType = user_type;
	}
	
	/**
	 * Sets the user's phone number
	 * @author Diana Gorun
	 * @param phoneNum
	 */
	public void setPhoneNumber(String phoneNum){
		phoneNumber = phoneNum;
	}
	//Getters
	
	/**
	 * @author Diana Gorun
	 * @return the user's phone number
	 */
	public String getPhoneNumber(){
		return phoneNumber;
	}
	/**
	 * @author Diana Gorun
	 * @return the user's userName
	 */
	public String getUserName(){
		return userName;
	}
	/**
	 * @author Diana Gorun
	 * @return user's first name
	 */
	public String getFirstName() 
	{
		return firstName;
	}
	
	/**
	 * @author Diana Gorun
	 * @return the user type
	 */
	public char getUserType()
	{
		if(Database.getUserEntries(userName) == null){
			return userType;
		}else{
			return 'C';
		}
	}
	
	/**
	 * @author Diana Gorun
	 * @return the user's last name
	 */
	public String getLastName() 
	{
		return lastName;
	}
	
	/**
	 * @author Diana Gorun
	 * @return the user's email adress
	 */
	public String getAddress() 
	{
		return eMail;
	}
	
	@Override 
	public String toString(){
		return userName;
	}
	@Override
	public boolean equals(Object o){
		if(o instanceof UserInfo){
			UserInfo u = (UserInfo)o;
			if(u.getUserName().equals(userName)){
				return true;
			}else{
				return false;
			}
		}else{
			return false;
		}
	}
}
